# demo02_read.py   readline/readlines
fr1 = open("/etc/hosts", mode="r")
# data = fr1.readlines()  # 存储行数据的列表
# print("data:", data)
# print(data[0])  # 获取第一行数据
# print(data[1])  # 获取第二行数据
for line in fr1:  # for line in fr1.readlines():
    print("line:", line, end="")
fr1.close()

fr = open("/etc/hosts", mode="r") # r:read
print(fr.readline(),end="")  # 读取第一行数据
print(fr.readline(),end="")  # 读取第二行数据
fr.close()